﻿
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
@*@using (Html.BeginForm("JsonClass", "JSONHelper", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.ValidationSummary(true)
*@
    <fieldset>
        <div class='form-group'>
          <div class='col-sm-8'>
            <textarea class="form-control" rows="5" name="jText" id="jText"></textarea>
          </div>
        </div>
        <div class='col-sm-1'>
            <button  class="btn btn-primary pull-left" id='btnTransfer'>TRANSFER</button>
            <div>&nbsp;</div>
            <button  class="btn btn-primary pull-left" id='btnSave'>SAVE</button>
        </div>
    </fieldset>
@*}*@
    <fieldset>
        <div id="container" class='col-sm-8' style='margin-top:5px'>

        </div>
    </fieldset>


<script>
    $(document).ready(function () {
        $('#btnTransfer').click(function () {
            $.ajax({
                type: "POST",
                url: '@Url.Action("JsonClass", "JSONHelper")',
                data: {
                    jText: $('#jText').val()

                },
                datatype: "html",
                success: function (data) {
                    $('#container').html('');
                    $('#container').html(data);
                }
            });
        });

        $('#btnSave').click(function () {
            $.ajax({
                type: "POST",
                url: '@Url.Action("Save", "JSONHelper")',
                data: {
                    jClass: $('#container').html()
                },
                datatype: "html",
                success: function (data) {
                    $('#container').html('');
                    $('#container').html(data);
                }
            });
        });

    });
</script>
